<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <title>意见箱</title>
    <link rel="stylesheet" type="text/css" href="../static/css/city-picker.css" th:href="@{/css/city-picker.css}">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}">
    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
    <link href="../static/lib/bootstrap/css/bootstrap.min.css" th:href="@{/lib/bootstrap/css/bootstrap.min.css}">
</head>
<body>
<div class="row" th:replace="_fragments :: menu(3)"></div>

<div class="m-container m-padded-tb-big animated fadeIn" id="sug">
    <div class="ui container">
        <div class="ui stackable grid">
            <div class="two wide column"></div>
            <div class="twelve wide column">
                <form class="ui form segment">
                    <h2 class="ui header m-padded-tb" style="text-align: center!important;">意见箱</h2>
                    <div class="field">
                        <textarea name="content" id="content" placeholder="希望您留下宝贵的意见！！！"></textarea>
                    </div>
                    <div class="ui primary submit button" id="ok">提交(Submit)</div>
                    <br><br>
                    <div class="ui error mini message"></div>
                    <br><br>
                </form>
            </div>
            <div class="two wide column"></div>
        </div>
        <div class="three wide column"></div>
    </div>
</div>
</div>

<th:block th:replace="_fragments :: script">
</th:block>

<script>
    $("#ok").click(function () {
        var content = $("#content").val();
        if (content.length === 0) {
            alert("请输入建议！！")
        } else {
            alert("222");
            $.ajax({
                url: "/input_suggest",
                type: "get",
                dataType: "json",
                data: {"content": content},
                success: function (result) {
                    if (result.code === 200) {
                        window.location.href = "/suggest";
                        alert("感谢您的建议...")
                    } else if (result.code === 500) {
                        alert("请登录！！！")
                    } else {
                        alert("发送错误");
                    }
                }
            });
        }
    })


</script>
</body>
</html>